package com.example.demo.service.impl;

import cn.hutool.core.lang.UUID;
import com.example.demo.annotion.Test;
import com.example.demo.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class TestServiceImpl implements TestService {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Override
    @Test
    @Scheduled(cron = "0 0/1 * * * ? ")
    public void test() {
      String rand = UUID.fastUUID().toString();
      redisTemplate.opsForValue().set("uuid",rand);
      log.info("random uuid:{}",rand);
    }
}
